using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CSharpCustomControls
{
    [ToolboxData("<{0}:FourthSample runat=server></{0}:FourthSample>")]
    public class FourthSample : WebControl
    {
        protected override void CreateChildControls()
        {
            System.Web.UI.WebControls.Button btn = new System.Web.UI.WebControls.Button();
            System.Web.UI.WebControls.TextBox txt1 = new System.Web.UI.WebControls.TextBox();
            System.Web.UI.WebControls.TextBox txt2 = new System.Web.UI.WebControls.TextBox();
            
            txt1.Text = "Hello,";
            this.Controls.Add(txt1);

            txt2.Text = "World ";
            this.Controls.Add(txt2);

            btn.Text = "In a Custom Control";
            this.Controls.Add(btn);

            
        }
        protected override void Render(HtmlTextWriter writer)
        {
            foreach(System.Web.UI.WebControls.WebControl ct in this.Controls)
            {
                if (ct.GetType().Name != "Button")
                    {
                        ct.RenderControl(writer);
                        writer.Write("<hr/>");
                }
        }

        }
    }
}
